class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        max_, sum_ = -101, 0
        for i in range(len(nums)):
            sum_ += nums[i] # 以此元素结尾的数组最大和
            if sum_ > max_:
                max_ = sum_
            sum_ = max(0, sum_) # 最大和不小于零，即不选
        return max_